package com.kern.pojo;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class ResponseResult {

    public static final int OK_CODE = 0;
    public static final int FAIL_CODE = -1;

    private static final String default_ok_msg = "success";


    private int code;
    private String message;
    private Object data;

    public ResponseResult(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static ResponseResult ok(String msg, Object data) {
        return new ResponseResult(OK_CODE, msg, data);
    }


    public static ResponseResult ok(Object data) {
        return new ResponseResult(OK_CODE, default_ok_msg, data);
    }

    public static ResponseResult fail(String msg, Object data) {
        return new ResponseResult(FAIL_CODE, msg, data);
    }

    public static ResponseResult fail(String msg) {
        return new ResponseResult(FAIL_CODE, msg, null);
    }
}
